PER.rover
Class Rover

java.lang.Object
  extended byPER.rover.control.RoverController
      extended byPER.rover.Rover

public class Rover
extends RoverController

High-level control of the Rover.


Field Summary
static java.lang.String defaultIP
          Default IP address
static java.lang.String topLevelDir
          Directory for saved files, logs etc.
static boolean USING_MARS_ROVER
          Tells my code whether we are using the mars rover or the prototype
 
Fields inherited from class PER.rover.control.RoverController
highLevelState, READ_TIMEOUT, receive, reliagram, state
 
Constructor Summary
Rover()
          Creates a new Rover
 
Method Summary
 java.util.Timer executeFunctionAtTime(java.util.TimerTask task, java.util.Date time)
          Schedules the specified task for execution at the specified time.
 java.util.Timer executeFunctionDelay(java.util.TimerTask task, long delay)
          Schedules the specified task for execution after the specified delay.
 java.util.Timer executeFunctionTimerAtTime(java.util.TimerTask task, java.util.Date firstTime, long period, boolean fixedRate)
          Schedules the specified task for repeated fixed-delay execution, beginning at the specified time.
 java.util.Timer executeFunctionTimerDelay(java.util.TimerTask task, long delay, long period, boolean fixedRate)
          Schedules the specified task for repeated fixed-delay execution, beginning after the specified delay.
 java.lang.String getCurrentIP()
          Returns the IP address currently being used.
static java.lang.String getDefaultIP()
          Loads the last used IP address from a saved file.
 long getTime()
          Returns the current system time in milliseconds.
static java.lang.String getTopLevelDir()
          Returns a String that is the path for top level directory.
 boolean saveImageToDisk(java.io.File f, java.awt.image.BufferedImage picture)
          Saves a given BufferedImage to a file as a jpg.
 boolean saveImageToDisk(java.lang.String filename, java.awt.image.BufferedImage picture)
          Saves a given BufferedImage to disk as a jpg at filename.
static void saveIP(java.lang.String IP)
          Saves the given IP address to a file so that it can be loaded the next time the program is executed.
 void setCurrentIP(java.lang.String ip)
          Sets the current IP address being used.
static void setTopLevelDir(java.lang.String s)
          Sets the top level directory and makes sure the new directory exists.
 boolean sleep(long duration)
          Sleeps for duration milliseconds.
 void stopExecuteFunction(java.util.Timer timer)
          Finishes executing a timer function.
 java.util.TimerTask timeLapse(int pan, int tilt, int width, int height, boolean UV, javax.swing.JLabel displayLabel)
          Returns a TimerTask that takes pictures and displays them to a specified JLabel.
 java.util.TimerTask timeLapse(int pan, int tilt, int width, int height, boolean UV, java.lang.String pathPrefix)
          Returns a TimerTask that takes pictures and saves them.
 java.util.TimerTask timeLapse(int pan, int tilt, int width, int height, boolean UV, java.lang.String pathPrefix, javax.swing.JLabel displayLabel)
          Returns a TimerTask that takes pictures, saves them to file, and displays them to a specified JLabel.
 
Methods inherited from class PER.rover.control.RoverController
closeComm, compareVersion, crab, getCalibration, getCameraProperties, getDriveCalibration, getMean, getScanList, getTurnCalibration, getVersion, goTo, goTo, headMove, initComm, initRobot, isConnected, killHighLevel, killRobot, look, quadTurn, refresh, scan, setAll, setCalibration, setLight, setPan, setScanList, setTilt, spin, startMotionDetection, startTrack, startTrack, stopStreaming, takePicture, takePicture, takeRawPicture, takeRecentPicture, turnTo, turnTo, updateHighLevel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

USING_MARS_ROVER

public static final boolean USING_MARS_ROVER
Tells my code whether we are using the mars rover or the prototype

See Also:
Constant Field Values

topLevelDir

public static java.lang.String topLevelDir
Directory for saved files, logs etc.


defaultIP

public static java.lang.String defaultIP
Default IP address

Constructor Detail

Rover

public Rover()
Creates a new Rover

Method Detail

setTopLevelDir

public static void setTopLevelDir(java.lang.String s)
Sets the top level directory and makes sure the new directory exists. If the directory does not exist, it is created. The top level directory is the directory for saved rover files and logs.


getTopLevelDir

public static java.lang.String getTopLevelDir()
Returns a String that is the path for top level directory. The top level directory is the directory for saved rover files and logs.


getCurrentIP

public java.lang.String getCurrentIP()
Returns the IP address currently being used.


setCurrentIP

public void setCurrentIP(java.lang.String ip)
Sets the current IP address being used.


getDefaultIP

public static java.lang.String getDefaultIP()
Loads the last used IP address from a saved file. If the file can not be opened, returns defaultIP.

Returns:
the last IP address saved or defaultIP

saveIP

public static void saveIP(java.lang.String IP)
Saves the given IP address to a file so that it can be loaded the next time the program is executed.

See Also:
getDefaultIP()

getTime

public long getTime()
Returns the current system time in milliseconds.

Returns:
The current system time in Milliseconds

saveImageToDisk

public boolean saveImageToDisk(java.lang.String filename,
                               java.awt.image.BufferedImage picture)
Saves a given BufferedImage to disk as a jpg at filename. The filename string should be a complete path, for example:

Parameters:
filename - Path at which to save the image
picture - Image to save
Returns:
false if the filename cannot be written to, or picture is NULL, or other error

saveImageToDisk

public boolean saveImageToDisk(java.io.File f,
                               java.awt.image.BufferedImage picture)
Saves a given BufferedImage to a file as a jpg.

Parameters:
f - The file where the image should be saved
picture - Image to save
Returns:
false if the file cannot be written to, picture is NULL, or other error

sleep

public boolean sleep(long duration)
Sleeps for duration milliseconds.

Parameters:
duration - Time to sleep, in milliseconds.
Returns:
false if sleep was interrupted

executeFunctionAtTime

public java.util.Timer executeFunctionAtTime(java.util.TimerTask task,
                                             java.util.Date time)
Schedules the specified task for execution at the specified time.

Parameters:
task - TimerTask function to execute
time - Time at which to execute the function
Returns:
null on error
See Also:
TimerTask, Timer, Date

executeFunctionTimerAtTime

public java.util.Timer executeFunctionTimerAtTime(java.util.TimerTask task,
                                                  java.util.Date firstTime,
                                                  long period,
                                                  boolean fixedRate)
Schedules the specified task for repeated fixed-delay execution, beginning at the specified time.

Parameters:
task - TimerTask function to execute
firstTime - The time to begin execution
period - Rate at which to execute the function, in milliseconds.
fixedRate - True if task should be executed relative to the initial start time, false if it should be executed relative to when the last task ended.
Returns:
null on error
See Also:
TimerTask, Timer, Date

executeFunctionDelay

public java.util.Timer executeFunctionDelay(java.util.TimerTask task,
                                            long delay)
Schedules the specified task for execution after the specified delay.

Parameters:
task - TimerTask function to execute
delay - Time to wait before executing the function, in milliseconds.
Returns:
null on error
See Also:
TimerTask, Timer

executeFunctionTimerDelay

public java.util.Timer executeFunctionTimerDelay(java.util.TimerTask task,
                                                 long delay,
                                                 long period,
                                                 boolean fixedRate)
Schedules the specified task for repeated fixed-delay execution, beginning after the specified delay.

Parameters:
task - TimerTask function to execute
delay - Time to wait before executing the function, in milliseconds.
period - Rate at which to execute the function, in milliseconds.
fixedRate - True if task should be executed relative to the initial start time, false if it should be executed relative to when the last task ended.
Returns:
null on error
See Also:
TimerTask, Timer

stopExecuteFunction

public void stopExecuteFunction(java.util.Timer timer)
Finishes executing a timer function.

Parameters:
timer - The timer to kill.
See Also:
Timer

timeLapse

public java.util.TimerTask timeLapse(int pan,
                                     int tilt,
                                     int width,
                                     int height,
                                     boolean UV,
                                     java.lang.String pathPrefix)
Returns a TimerTask that takes pictures and saves them. The returned TimerTask is suitable for the task scheduling functions to execute. This can be used as the task for executeFunctionTimerAtTime or executeFunctionTimerDelay.

Parameters:
pan - The pan value in degrees at which to take the picture
tilt - The tilt vale in degrees at which to take the picture
width - The width of the image in pixels
height - The height of the image in pixels
UV - True if the UV light should be on for the picture, false otherwise
pathPrefix - The path where time-lapse pictures should be saved. They will get a suffix of a sequence number plus ".jpg"
Returns:
a TimerTask which can be used as the task for executeFunctionTimerAtTime or executeFunctionTimerDelay
See Also:
TimerTask, executeFunctionTimerAtTime(java.util.TimerTask, java.util.Date, long, boolean), executeFunctionTimerDelay(java.util.TimerTask, long, long, boolean)

timeLapse

public java.util.TimerTask timeLapse(int pan,
                                     int tilt,
                                     int width,
                                     int height,
                                     boolean UV,
                                     javax.swing.JLabel displayLabel)
Returns a TimerTask that takes pictures and displays them to a specified JLabel. The returned TimerTask is suitable for the task scheduling functions to execute. This can be used as the task for executeFunctionTimerAtTime or executeFunctionTimerDelay.

Parameters:
pan - The pan value in degrees at which to take the picture
tilt - The tilt vale in degrees at which to take the picture
width - The width of the image in pixels
height - The height of the image in pixels
UV - True if the UV light should be on for the picture, false otherwise
displayLabel - An optional JLabel to display the images to as they are taken.
Returns:
a TimerTask which can be used as the task for executeFunctionTimerAtTime or executeFunctionTimerDelay
See Also:
TimerTask, executeFunctionTimerAtTime(java.util.TimerTask, java.util.Date, long, boolean), executeFunctionTimerDelay(java.util.TimerTask, long, long, boolean)

timeLapse

public java.util.TimerTask timeLapse(int pan,
                                     int tilt,
                                     int width,
                                     int height,
                                     boolean UV,
                                     java.lang.String pathPrefix,
                                     javax.swing.JLabel displayLabel)
Returns a TimerTask that takes pictures, saves them to file, and displays them to a specified JLabel. The returned TimerTask is suitable for the task scheduling functions to execute. This can be used as the task for executeFunctionTimerAtTime or executeFunctionTimerDelay.

Parameters:
pan - The pan value in degrees at which to take the picture
tilt - The tilt vale in degrees at which to take the picture
width - The width of the image in pixels
height - The height of the image in pixels
UV - True if the UV light should be on for the picture, false otherwise
pathPrefix - An optional path where time-lapse pictures should be saved. If pathPrefix is null, pictures will not be saved. If pathPrefix is not null, pictures will be saved with a suffix of a sequence number plus ".jpg"
displayLabel - An optional JLabel to display the images to as they are taken. displayLabel can be null if images are not to be displayed.
Returns:
a TimerTask which can be used as the task for executeFunctionTimerAtTime or executeFunctionTimerDelay
See Also:
TimerTask, executeFunctionTimerAtTime(java.util.TimerTask, java.util.Date, long, boolean), executeFunctionTimerDelay(java.util.TimerTask, long, long, boolean)